package cn.chenxiejia;

import net.coobird.thumbnailator.Thumbnailator;
import net.coobird.thumbnailator.Thumbnails;

import java.io.File;
import java.io.IOException;

/**
 * @version : V1.0
 * @program: maven
 * @ClassName: Imges9
 * @Description: thumbmailator组件对图像的使用
 * @Author: chenxiejia
 * @Date: 2022/1/26 0:57
 */
public class Imges9 {
    public static void main(String[] args) {
        try {
            //复制
            Thumbnailator.createThumbnail(new File("2.png"), new File("21.png"), 300, 200);
            //scale缩略比例，rotate旋转角度，
            Thumbnails.of(new File("2.png")).scale(0.8).rotate(60).toFile(new File("22.png"));
            //outputFormat转换格式，.size大小
            Thumbnails.of("2.png").outputFormat("gif").size(100, 100).toFile("23.gif");
            //sourceRegion裁剪
            Thumbnails.of("2.png").scale(1.0).sourceRegion(0, 0, 300, 300).toFile("24.png");
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
